<?php
/**
 * Created by PhpStorm.
 * User: 68008000
 * Date: 2017/11/14
 * Time: 23:52
 */

namespace app\common\model;


use think\Model;

class Webset extends Model
{
    //连接数据库
    protected $table= 'webset';
    protected $pk= 'wid';
    //主页
    public function index(){
        //获取数据库数据
        $data = db('webset')->order('wid desc')->select();
        return $data;
    }
    //异步修改
    public function edit($data){
        $result = $this->validate(
            ['value'  => 'require',],
            ['value.require' => '网站配置值不能为空',]
        )->save($data,[$this->pk => $data['wid']]);
        if(false === $result){
            // 验证失败 输出错误信息
            return ['valid'=>0,'msg'=>$this->getError()];
        }else{
            //修改成功
            return ['valid'=>1,'msg'=>'修改成功'];
        }

    }
}
